package com.edu.service.impl;

import java.util.List;

import com.edu.dao.ProblemDao;
import com.edu.dao.impl.ProblemDaoImpl;
import com.edu.entiy.Book;
import com.edu.entiy.History;
import com.edu.entiy.Problem;
import com.edu.service.ProblemService;
import com.edu.utils.PageTool;
import com.edu.dao.ProblemDao;

public class ProblemServiceImpl implements ProblemService {
	private ProblemDao problemDao = new ProblemDaoImpl();
	@Override
	public PageTool<Problem> page(String currentPage, String pageSize,String word,Integer userId) {
		// TODO Auto-generated method stub
		//
		int count=problemDao.selectProblemCount(userId);
		System.out.println(count);
		//初始化分页工具
		PageTool<Problem> pageTool = new PageTool<Problem>(count,currentPage,pageSize);
		List<Problem> Problem =  problemDao.selectPageBrand(word,pageTool.getStartIndex() , pageTool.getPageSize(),userId);
		pageTool.setRows(Problem);
		return pageTool;	
	}
	@Override
	public int addProblem(Problem Problem) {
		// TODO Auto-generated method stub
		return problemDao.addProblem(Problem);
	
	}
	@Override
	public int updateProblem(int pid, String status) {
		// TODO Auto-generated method stub
		return problemDao.updateProblem(pid, status);
	}
	@Override
	public int deleteProblem(int pid) {
		// TODO Auto-generated method stub
		return problemDao.deleteProblem(pid);
	}

}
